package TransactionImplementation

import (
	"PaySalary/AbstractTransactions"
	"PaySalary/DataBase"
	"PaySalary/Model"
	"PaySalary/ModelImplementation"
	"reflect"
)

type ChangeUnaffiliatedTransaction struct {
	AbstractTransactions.ChangeAffiliationTransaction
}

func (ut *ChangeUnaffiliatedTransaction)NewChangeUnaffiliatedTransaction(empid int)  {
	ut.ChangeAffiliationTransaction.NewChangeAffiliationTransaction(empid)
}

func (ut *ChangeUnaffiliatedTransaction) RecordMembership(e Model.Employee)  {
	af := e.GetItsAffiliation()
	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation{}) {
		//指针
		uaf := af.(*ModelImplementation.UnionAffiliation)
		memberId := uaf.GetMemberId()
		DataBase.PayrollDatabase.RemoveUnionMember(ut, memberId)
	}
}

func (ut *ChangeUnaffiliatedTransaction)GetAffiliation() Model.Affiliation {
	return Model.NoAffiliation{}
}